package com.gnerv.battle.boot.module.base.model.bo;

import com.gnerv.battle.boot.common.tools.DateTimeTools;
import com.gnerv.battle.boot.common.tools.GsonTools;
import com.gnerv.battle.boot.module.base.model.entity.RoleDataPermission;
import lombok.Data;

import java.util.Set;

/**
 * @author Gnerv LiGen
 */
@Data
public class RoleDatePermissionBO {

    private String roleUkId;
    private Set<String> roleUkIdList;
    private Set<String> orgUkIdList;

    public RoleDataPermission toCreateRoleDataPermission() {
        RoleDataPermission roleDataPermission = new RoleDataPermission();
        roleDataPermission.setRoleUkId(roleUkId);
        roleDataPermission.setRole(GsonTools.GSON.toJson(roleUkIdList));
        roleDataPermission.setOrg(GsonTools.GSON.toJson(orgUkIdList));
        roleDataPermission.setGmtCreate(DateTimeTools.currentTimeMillis());
        roleDataPermission.setGmtModified(DateTimeTools.currentTimeMillis());
        return roleDataPermission;
    }

    public RoleDataPermission toUpdateRoleDataPermission() {
        RoleDataPermission roleDataPermission = new RoleDataPermission();
        roleDataPermission.setRoleUkId(roleUkId);
        roleDataPermission.setRole(GsonTools.GSON.toJson(roleUkIdList));
        roleDataPermission.setOrg(GsonTools.GSON.toJson(orgUkIdList));
        roleDataPermission.setGmtModified(DateTimeTools.currentTimeMillis());
        return roleDataPermission;
    }

}
